<template>
  <div class="add-node-btn-box">
    <div class="add-node-btn">
      <Poptip placement="right-start" v-model="visible">
        <button class="btn" type="button">
          <span class="iconfont"></span>
        </button>
        <div class="add-node-popover-body" slot="content">
          <a class="add-node-popover-item approver" @click="addType(1)">
            <div class="item-wrapper">
              <span class="iconfont"></span>
            </div>
            <p>单节点</p>
          </a>
          <a class="add-node-popover-item condition" @click="addType(4)">
            <div class="item-wrapper">
              <span class="iconfont"></span>
            </div>
            <p>多节点</p>
          </a>
        </div>
      </Poptip>
    </div>
  </div>
</template>
<script>
export default {
  props: ["childNodeP"],
  data() {
    return {
      visible: false,
    };
  },
  methods: {
    addType(type) {
      this.visible = false;
      if (type != 4) {
        var data;
        if (type == 1) {
          data = {
            nodeName: "单节点",
            error: true,
            type: 1,
            scriptName: "",
            settype: 1,
            selectMode: 0,
            selectRange: 0,
            directorLevel: 1,
            examineMode: 1,
            noHanderAction: 1,
            examineEndDirectorLevel: 0,
            childNode: this.childNodeP,
            nodeUserList: [],
          };
        }
        this.$emit("update:childNodeP", data);
      } else {
        this.$emit("update:childNodeP", {
          nodeName: "路由",
          type: 4,
          childNode: null,
          conditionNodes: [
            {
              nodeName: "条件1",
              error: true,
              type: 3,
              scriptName: "",
              conditionList: [],
              nodeUserList: [],
              childNode: this.childNodeP,
            },
            {
              nodeName: "条件2",
              type: 3,
              scriptName: "",
              conditionList: [],
              nodeUserList: [],
              childNode: null,
            },
          ],
        });
      }
    },
  },
};
</script>